package Csp.Solvers;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import Csp.Model.Csp;
import Csp.Model.Variable;

public class TrivialHeuristics implements IHeuristics {

	@Override
	public Variable selectVariable(List<Variable> instance, Csp csp) {
		Set<Integer> instanced = new HashSet<Integer>();
		for (Variable var : instance) {
			instanced.add(var.getId());
		}
		//Sx a dx: la prima non istanziata
		for (Variable variable : csp.getVariables()) {
			if(!instanced.contains(variable.getId()))
				return variable;
		}
		return null;
	}
	
	@Override
	public Integer selectValue(Variable variable, Set<Integer> domain, Csp csp) {
		Integer first = domain.iterator().next();
		domain.remove(first);
		return first;
	}
	
}
